<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/metisMenu/metisMenu_custom.css" />
<link rel="stylesheet" href="static/css/style.css" />
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="static/jqueryValidate/jquery.validate.min.js"></script>
<script src="static/jqueryValidate/additional-methods.min.js"></script>
<script src="static/jqueryValidate/localization/messages_zh.min.js"></script>
<script src="static/moment/moment.js"></script>
<script src="static/moment/locale/zh-cn.js"></script>
<script src="static/js/base-loading.js"></script>
<title>已审核项目列表</title>
</head>

<body>
<div class="content-container" data-options="region:'center'" title="已审核项目列表">
<div class="panel-header"><div class="panel-title">已审核项目列表</div></div>
		<table id="pro_table" class="easyui-datagrid" style="height: 100%">
		</table>
	</div>
	<div id="pro_tb">
		<div>
			类别：<select id="kind" class="easyui-combobox"  name="kind" style="width:120px;" data-options="panelHeight:'auto',
			editable:false">
					<option value="planmain">主计划</option>
					<option value="plandaily">日计划</option>
				    <option value="budget">预算</option>
				    <option value="urgent">工程联系单</option>
				    <option value="capital">资金申请</option>
				    <option value="quantities">工程量</option>
				    <option value="goods">物资</option>
				    <option value="goodscurrent">物资流动</option>
				</select>
		</div>
	</div>
	<div style="display: none">
	    <div id="displayAtt" class="datagrid-toolbar" style="width:80%;max-height:80%;padding:5px;top:30px;text-align:center;">
	    </div>
	</div>
</body>
<script>
	var currentPro;
	var kind = "";
					
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "planMainReviewed.do",
			method : 'get',
			onSelect : function(index, row) {
				currentPro = row;
			},
			columns : [ [ {
				field : 'name',
				title : '项目',
				width : '',
				formatter : function(value,row,index){
					if(row.item){
						return row.item.name;
					}
				}
			}, {
				field : 'content',
				title : '主计划内容',
				width : '400px'
			},{
				field : 'reason',
				title : '拒绝理由',
				width : ''
			}, {
				field : 'status',
				title : '状态',
				width : '',
				formatter : function(value, row, index) {
					if(value==4){
						return value='已审';
					}else if(value==3){
						return value='已拒绝';
					}else if(value==6){
						return value='待二级审核';
					}else if(value==7){
						return value='待一级审核';
					}
				}
			} ] ]
		});
	}); 
	
	$(function () {  
     $('#kind').combobox({  
          onChange: function (newValue, oldValue) {  
            kind = newValue; 
            switch(kind){
	            case 'planmain':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "planMainReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.item){
										return row.item.name;
									}
								}
							}, {
								field : 'content',
								title : '主计划内容',
								width : '400px'
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
	            	break;
	            case 'plandaily':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "planDailyReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.planMain){
										return row.planMain.item.name;
									}
								}
							}, {
								field : 'content',
								title : '日计划内容',
								width : '400px'
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
	            	break;
	            case 'budget':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "budgetSubItemReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.main){
										return row.main.item.name;
									}
								}
							}, {
								field : 'content',
								title : '主预算内容',
								width : '400px'
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
	            	break;
	            case 'urgent':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "urgentApplyReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.item){
										return row.item.name;
									}
								}
							}, {
								field : 'content',
								title : '工程联系单内容',
								width : '400px'
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							},  {
								field : 'attachment',
								title : '附件',
								width : '',
								formatter : function(value, row, index) {
									if(row.attachments.length>0){
										return '<a href="#" style="color:red;" onclick="viewAtt('+index+');">点击查看</a>';
									}else{
										return '';
									}
									
								}
							} ] ]
						});
	            	break;
	            case 'capital':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "capitalApplyReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.item){
										return row.item.name;
									}
								}
							}, {
								field : 'content',
								title : '资金申请内容',
								width : '400px'
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
	            	break;
	            case 'quantities':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "QuantitiesReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'projectname',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.item){
										return row.item.name;
									}
								}
							}, {
								field : 'name',
								title : '名称',
								width : ''
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}
								}
							} ] ]
						});
				break;
			 case 'goods':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "GoodsReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'projectname',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.item){
										return row.item.name;
									}
								}
							}, {
								field : 'name',
								title : '名称',
								width : ''
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
				break;
			 case 'goodscurrent':
	            	$('#pro_table').datagrid({
							rownumbers : true,
							singleSelect : true,
							pagination : true,
							fitColumns : false,
							border : false,
							striped : true,
							toolbar : '#pro_tb',
							url : "GoodsCurrentReviewed.do",
							method : 'get',
							onSelect : function(index, row) {
								currentPro = row;
							},
							columns : [ [ {
								field : 'name',
								title : '项目',
								width : '',
								formatter : function(value,row,index){
									if(row.goods.item){
										return row.goods.item.name;
									}
								}
							}, {
								field : 'type',
								title : '类别',
								width : '',
								formatter : function(value,row,index){
									if(value==1){
										return "+"+row.difference;
									}else{
										return "-"+row.difference;
									}
								}
							},{
								field : 'reason',
								title : '拒绝理由',
								width : ''
							}, {
								field : 'status',
								title : '状态',
								width : '',
								formatter : function(value, row, index) {
									if(value==4){
										return value='已审';
									}else if(value==3){
										return value='已拒绝';
									}else if(value==6){
										return value='待二级审核';
									}else if(value==7){
										return value='待一级审核';
									}
								}
							} ] ]
						});
				break;
            }
          }  
      });  
 	});  
	function viewAtt(index){
		var row = $('#pro_table').datagrid('getRows')[index];
		var tb="";
		$.each(row.attachments,function(i,val){
			if(val.type=='image'){
				tb+= '<div id="att'+val.id+'" class="col-md-3" ><img onclick="window.open(\''+val.url+'\',\'_blank\', \' toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\');" style="width:100px;height:100px;" src="'+val.url+'" alt="查看全图"><br>';
				tb+= '<span>'+val.name+'</span><br>';
				tb+= '<a href="javascript:void(0)" class="easyui-linkbutton l-btn l-btn-small" onclick="attachmentFile('+val.id+',\''+val.name+'\')"><span class="l-btn-left"><span class="l-btn-text">下载</span></span></a>';
				tb+= '</div>';
			}else{
				tb+= '<div id="att'+val.id+'" class="col-md-3" ><img onclick="window.open(\''+val.url+'\',\'_blank\', \' toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no\');" style="width:100px;height:100px;" src="static/bootstrap/img/'+val.type+'.png" alt="查看全图"><br>';
				tb+= '<span>'+val.name+'</span><br>';
				tb+= '<a href="javascript:void(0)" class="easyui-linkbutton l-btn l-btn-small" onclick="attachmentFile('+val.id+',\''+val.name+'\')"><span class="l-btn-left"><span class="l-btn-text">下载</span></span></a>';
				tb+= '</div>';
			}
		});
		$('#displayAtt').empty().html(tb);
		$('#displayAtt').dialog({
            title: '附件',
            resizable: true,
            closed: false,
            cache: false,
            modal: true
        });
	}
	
</script>

</html>